<?php
//返回给定长度的随机字符串
function random_text($count, $rm_similar = false)
{
    //创建字符数组
    $chars = array_flip(array_merge(range('A', 'Z'), range('0', '9')));
    //删除相似字符
    if ($rm_similar) {
        unset($chars['O'], $chars['0'], $chars['1'], $chars['I'], $chars['l']);
    }
     //生成随机字符文本
    $text = '';
    for ($i = 0; $i < $count; $i++) {
        $text .= array_rand($chars);
    }
    return $text;
}